package com.xiyuan.smartutils.template.engine.statement;

import com.xiyuan.smartutils.Validates;
import com.xiyuan.smartutils.template.engine.StatementParser;
import com.xiyuan.smartutils.template.engine.TagType;
import com.xiyuan.smartutils.template.engine.VariableMap;
import com.xiyuan.smartutils.template.engine.exception.StatementException;

import java.io.PrintWriter;

/***
 * 标签结束
 *
 * @version v1.0.0 @author lgz 2020-7-29 新建与整理
 */
public class _BLOCK_END extends Statement {
    
    private static final long serialVersionUID = 1L;
    
    public _BLOCK_END(StatementParser parser) {
        super(parser);
    }
    
    @Override
    protected void build(VariableMap variableMap, PrintWriter out) {
        out.print(this.getStatement());
    }
    
    public TagType getType() {
        return TagType.BLOCK_END;
    }
    
    @Override
    public boolean parseTag(StatementParser parser) throws StatementException {
        
        while (parser.hasNext()) {
            char c = parser.next();
            if (Validates.isWhitespace(c)) {continue;}
            
            return c == '>';
        }
        return false;
    }
    
}
